package com.njupt.Collection;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author 2506165018
 * @version 1.0
 * @data 2025-07-29 17:58:33
 */
public class TestBigDecimal {

    public static void main(String[] args) {
        BigDecimal decimal1 = new BigDecimal("0.1"); //0.1
        BigDecimal decimal2 = new BigDecimal(0.1); //0.1000000000000000055511151231257827021181583404541015625

        System.out.println(decimal1);
        System.out.println(decimal2);

        BigDecimal decimal3 = new BigDecimal("0.10");
        System.out.println(decimal1.equals(decimal3)); //false
        System.out.println(decimal1.compareTo(decimal3) == 0 ? true : false); //true

        BigDecimal decimal4 = new BigDecimal(2);
        BigDecimal decimal5 = new BigDecimal(3);
        System.out.println(decimal4.divide(decimal5,2,RoundingMode.HALF_UP));

    }
}
